package com.example.courseservice.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Getter
@Setter
@Entity
@Table(name = "chapter")
public class Chapter {
    @Id
    @Column(name = "chapter_id", nullable = false, length = 100)
    private String chapterId;

    @Column(name = "chapter_name", nullable = false, length = 100)
    private String chapterName;

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @JoinColumn(name = "course_id", nullable = false)
    private Course course;
}